/*
    信道模块编译测试
*/

#include "../../src/server/channel.hpp"

int main()
{
    mq::ChannelManager::ChannelManagerPtr channel_manager_ptr = std::make_shared<mq::ChannelManager>();

    // 打开信道
    channel_manager_ptr->openChannel("1", mq::ConsumerManager::ConsumerManagerPtr(), muduo::net::TcpConnectionPtr(), mq::ProtobufCodecPtr(), 
        std::make_shared<mq::VirtualHost>("host1", "./data/mate.db", "./data"), mq::ThreadPool::ThreadPoolPtr());

    // 获取信道
    mq::Channel::ChannelPtr channel_ptr = channel_manager_ptr->getChannel("1");
    if(!channel_ptr)
        std::cout << "channel not found" << std::endl;
    else
        std::cout << "channel found" << std::endl;

    // 关闭信道
    channel_manager_ptr->closeChannel("1");

    // 获取信道
    channel_ptr = channel_manager_ptr->getChannel("1");
    if(!channel_ptr)
        std::cout << "channel not found" << std::endl;
    else
        std::cout << "channel found" << std::endl;

    return 0;
}